In computing, “garbage collection” refers to a technique used to manage in an automated fashion memory blocks that have been allocated for use by programs using objects associated with a runtime system, without requiring that the programs themselves or other application code with which such memory blocks are associated keep track of and when finished de-allocate said memory blocks. Blocks that are roots (e.g., stack local variables and global variables and those registered as being held externally) and/or that are reachable from a root block via a chain of one or more explicit or “strong” references are kept alive, while blocks that are no longer reachable, indicating they are no longer in use (i.e., referenced by) by any live object, are “garbage collected”, that is, de-allocated and returned to the runtime system, thus making available for other use the memory allocated previously to such objects. Providing a “garbage collected” runtime system simplifies the task of application developers and avoids problems, such as “memory leaks”, crashes due to stale references to prematurely de-allocated blocks, and other related failures, that can occur if memory resources allocated to application objects are not released when and only when such objects are no longer in use.
Garbage collection typically has been performed by a central garbage collection or thread for all threads associated with objects stored in a memory “heap”. In so-called “generational” garbage collection, allocation of memory to new objects and the writing into relatively old objects of references to such new objects are tracked, which allows for a quicker but not comprehensive garbage collection to be performed with respect to newer objects that are no longer reachable, since many objects (e.g., temporary objects) are created, used, and no longer referenced and/or needed very shortly after their creation, such that by finding and collecting only those relatively newer objects that are no longer reachable memory associated with a good proportion of unreachable objects can be recovered than would be possible if older objects had to be checked as well. In both traditional and generational garbage collection, typically a set of objects that spans across all threads are checked for reachable and objects that are not determined to be reachable are garbage collected. Some garbage collectors may move objects that are not garbage collected, for example to defragment the heap, which requires that all references to such objects be updated. A “conservative” or “non-moving” garbage collector, on the other hand, is one that does not move objects found to be reachable. A “concurrent” garbage collector is one that does not require that all threads be halted while garbage collection is being performed.